package com.hyundaihds.hdscontacts;

import android.app.*;
import android.content.*;
import android.database.*;
import android.database.sqlite.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.view.View.OnClickListener;

public class Main2 extends ListActivity implements View.OnClickListener {
	/** Called when the activity is first created. */

	//ProductDBHelper mHelper;

	private ListView mPhotosList;
	String name = "";
	

    ProductDBHelper mHelper;
    
    
    

	private static final String[] PHOTOS_NAMES = new String[] { "조직 검색",
			"이름 검색", "좌석 검색", };

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// setContentView(R.layout.main2);
		
		
		
		//mHelper = new ProductDBHelper(this);
		
		
		
		
		
		
		mHelper = new ProductDBHelper(this);
		Cursor cursor;
		
		SQLiteDatabase db = mHelper.getWritableDatabase();
		

		cursor = db.rawQuery("SELECT * FROM HDS", null);
		startManagingCursor(cursor);
		
		

		while (cursor.moveToNext()) {
			String aa = cursor.getString(1);
			// Toast.makeText(this, aa, Toast.LENGTH_SHORT).show();
		}

		setListAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, PHOTOS_NAMES));
		getListView().setTextFilterEnabled(true);

	}

	public void onListItemClick(ListView l, View v, int position, long id) {
		name = PHOTOS_NAMES[position];

		// 조직검색 이벤트
		if (position == 0) {
			Intent intent = new Intent(Main2.this, Menu1.class);
			
	
			startActivity(intent);
			return;
			// 이름검색 이벤트
		} else if (position == 1) {
			Intent intent = new Intent(Main2.this, Menu2.class);

			startActivity(intent);
			return;
			// 좌석검색 이벤트
		} else if (position == 2) {
			Intent intent = new Intent(Main2.this, Menu3.class);
			startActivity(intent);
			return;

		}
		Intent intent = new Intent(Main2.this, Menu1.class);
		startActivity(intent);

	}

	public void onClick(View v) {
		// TODO Auto-generated method stub

	}

}

/*class ProductDBHelper extends SQLiteOpenHelper {
	public ProductDBHelper(Context context) {
		super(context, "DJ1.db", null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.ex
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}
}
*/



class ProductDBHelper extends SQLiteOpenHelper{
	public ProductDBHelper(Context context)
	{		
		super(context, "HDSDB.db", null, 1);		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		
		db.execSQL("CREATE TABLE HDS ( _id INTEGER PRIMARY KEY AUTOINCREMENT, "
		+ " IAID TEXT, NAME TEXT, TEAM_CODE TEXT, TEAM_NM TEXT, POS_NM TEXT, PHONE1 TEXT, " +
				"PHONE2 TEXT, E_MAIL TEXT, FLOOR_NUM INTEGER, ETC TEXT);");
		
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0406', '김돈조', 'GI', '일반보험팀', '차장', '02-721-0273', '010-8812-7330', 'rlaehswh@nate.com', '19', '3');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0227', '최재훈', 'GI', '일반보험팀', '과장', '02-721-0274', '010-8706-6186', 'chlwogns@nate.com', '19', '2');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1127', '백세영', 'GI', '일반보험팀', '과장', '02-721-0270', '010-2395-9030', 'qortpdud@nate.com', '19', '3');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0098', '신정아', 'GI', '일반보험팀', '과장', '02-721-0267', '010-3230-9493', 'tlswjddk@nate.com', '19', '4');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1300', '김찬희', 'GI', '일반보험팀', '과장', '02-721-0263', '010-4769-1804', 'rlacksgml@nate.com', '19', '4');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1207', '정성원', 'GI', '일반보험팀', '차장', '02-721-0262', '010-3194-8749', 'wjdtjddnjs@nate.com', '19', '4');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0307', '이남호', 'GI', '일반보험팀', '대리', '02-721-0268', '010-9897-7564', 'dlskagh@nate.com', '19', '4');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1345', '하승섭', 'GI', '일반보험팀', '대리', '02-721-0276', '010-3668-7455', 'gktmdtjq@nate.com', '19', '2');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0435', '김세형', 'GI', '일반보험팀', '대리', '02-721-0271', '010-9600-3700', 'rlatpgud@nate.com', '19', '3');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1133', '송현우', 'GI', '일반보험팀', '사원', '02-721-0272', '010-9900-6363', 'thdgusdn@nate.com', '19', '3');");
		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1329', '권대중', 'GI', '일반보험팀', '사원', '02-721-0275', '010-2344-0477', 'routerospf@naver.com', '19', '2');");

	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}


}











//	@Override
//	public void onCreate(SQLiteDatabase db) {
//		// TODO Auto-generated method stub
//
//		// 한번만 생성하면 된다
//		/*db.execSQL("CREATE TABLE HDS ( _id INTEGER PRIMARY KEY AUTOINCREMENT, "
//				+ " IAID TEXT, NAME TEXT, TEAM_CODE TEXT, TEAM_NM TEXT, POS_NM TEXT, PHONE1 TEXT, PHONE2 TEXT, E_MAIL TEXT, FLOOR_NUM INTEGER, ETC TEXT);");
//
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0406', '김돈조', 'GI', '일반보험팀', '차장', '02-721-0273', '010-8812-7330', 'rlaehswh@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0227', '최재훈', 'GI', '일반보험팀', '과장', '02-721-0274', '010-8706-6186', 'chlwogns@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1127', '백세영', 'GI', '일반보험팀', '과장', '02-721-0270', '010-2395-9030', 'qortpdud@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0098', '신정아', 'GI', '일반보험팀', '과장', '02-721-0267', '010-3230-9493', 'tlswjddk@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1300', '김찬희', 'GI', '일반보험팀', '과장', '02-721-0263', '010-4769-1804', 'rlacksgml@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1207', '정성원', 'GI', '일반보험팀', '차장', '02-721-0262', '010-3194-8749', 'wjdtjddnjs@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0307', '이남호', 'GI', '일반보험팀', '대리', '02-721-0268', '010-9897-7564', 'dlskagh@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1345', '하승섭', 'GI', '일반보험팀', '대리', '02-721-0276', '010-3668-7455', 'gktmdtjq@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA0435', '김세형', 'GI', '일반보험팀', '대리', '02-721-0271', '010-9600-3700', 'rlatpgud@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1133', '송현우', 'GI', '일반보험팀', '사원', '02-721-0272', '010-9900-6363', 'thdgusdn@nate.com', '19', '-');");
//		db.execSQL("INSERT INTO HDS VALUES (null, 'IA1329', '권대중', 'GI', '일반보험팀', '사원', '02-721-0275', '010-2344-0477', 'routerospf@naver.com', '19', '-');");
//*/
//	}
//
//	@Override
//	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
//		// TODO Auto-generated method stub
//		db.execSQL("DROP TABLE IF EXISTS product");
//		onCreate(db);
//	}

